package com.javaee.xiangyang.converter;

import com.javaee.xiangyang.entity.enmu.impl.CommentState;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

@Component
public class CommentStateConverter implements Converter<String, CommentState> {

    @Override
    public CommentState convert(String s) {
        for (CommentState commentState : CommentState.values()){
            if (commentState.getCode() == Integer.parseInt(s)){
                return commentState;
            }
        }
        return null;
    }

}
